package com.atguigu.gmall.search.pojo;

import lombok.AllArgsConstructor;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author Jia Fa
 * @create 2021-12-06 13:59
 */
@Data
@Document(indexName = "goods", shards = 3, replicas = 2)
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Goods {
    //一个good对象对应一个sku对象
    //sku商品列表字段
    @Id
    private Long skuId;
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String title;
    @Field(type = FieldType.Keyword,index = false)
    private String defaultImage;
    @Field(type = FieldType.Keyword,index = false)
    private String subtitle;
    @Field(type = FieldType.Double)
    private BigDecimal price;

    //排序 过滤字段
    @Field(type = FieldType.Long)
    private Long sales; //销量
    @Field(type = FieldType.Date,format = DateFormat.date_time)
    private Date createTime; //创建时间
    @Field(type = FieldType.Boolean)
    private Boolean store = false;  //有货
    // 规格参数过滤字段
    // 品牌聚合字段
    @Field(type = FieldType.Long)
    private Long brandId;
    @Field(type = FieldType.Keyword)
    private String brandName;
    @Field(type = FieldType.Keyword)
    private String logo;
    //分类
    @Field(type = FieldType.Long)
    private Long categoryId;
    @Field(type = FieldType.Keyword)
    private String categoryName;
    //规格参数attr字段

    @Field(type = FieldType.Nested) //嵌套
    private List<SearchAttrValueVo> attrList;




}
